Use Windows.pkg
Use DFClient.pkg
Use cDoctorDataDictionary.dd
Use DFEntry.pkg
Use OfficeTimesSL.dg
Use dfLine.pkg

Register_Function ValidateLastName Integer iColumn String sValue Returns Boolean
Register_Function ValidateFirstName Integer iColumn String sValue Returns Boolean
Register_Function ValidateDoctor# Integer iColumn Integer iValue Returns Boolean
Register_Function ValidateTime Integer iColumn Integer iValue Returns Boolean

Deferred_View Activate_oDoctorSetup for ;
Object oDoctorSetup is a dbView
    Property String psMboxCaption "Doctor Setup"
    Set Border_Style to Border_ClientEdge
    Set Size to 217 227
    Set Location to 4 4
    Set Label to "Doctor Setup"
    Set Icon to "doctor_plus.ico"
    
    Object oDOCTOR_DD is a cDoctorDataDictionary
        Set Field_Validate_msg Field DOCTOR.DOCTOR# to get_ValidateDoctor#
        Set Field_Validate_msg Field DOCTOR.LAST_NAME to get_ValidateLastName
        Set Field_Validate_msg Field DOCTOR.FIRST_NAME to get_ValidateFirstName
        Set Field_Validate_msg Field DOCTOR.LUNCH_HOUR to get_ValidateTime
        Set Field_Validate_msg Field DOCTOR.START_TIME to get_ValidateTime
        Set Field_Validate_msg Field DOCTOR.END_TIME to get_ValidateTime
        
        Function Request_Validate Returns Integer
            Integer iStart iLunch iEnd
            Boolean bFail
            
            Forward Get Request_Validate to bFail
            
            Get Field_Current_Value Field DOCTOR.START_TIME to iStart
            Get Field_Current_Value Field DOCTOR.LUNCH_HOUR to iLunch
            Get Field_Current_Value Field DOCTOR.END_TIME to iEnd
            If (not(bFail)) Begin
                If ((iStart > iLunch) or (iStart > iEnd)) Begin
                    Move True to bFail
                    Send Info_Box "Start time must be before lunch time and end time." (psMboxCaption(Self))
                End
            End
            If (not(bFail)) Begin
                If ((iLunch > iEnd)) Begin
                    Move True to bFail
                    Send Info_Box "Lunch time must be before end time." (psMboxCaption(Self))
                End
            End
            Function_Return bFail
        End_Function
        
        Function ValidateLastName Integer iColumn String sValue Returns Boolean
            Boolean bFail
            Move False to bFail
            If (sValue = "") Begin
                Move True to bFail
                Send Info_Box "Please enter a last name." (psMboxCaption(Self))
            End
            Function_Return bFail
        End_Function
    
        Function ValidateFirstName Integer iColumn String sValue Returns Boolean
            Boolean bFail
            Move False to bFail
            If (sValue = "") Begin
                Move True to bFail
                Send Info_Box "Please enter a first name." (psMboxCaption(Self))
            End
            Function_Return bFail
        End_Function
    
        Function ValidateDoctor# Integer iColumn Integer iSSN Returns Boolean
            Boolean bFail
            Move False to bFail
            If (iSSN = 0) Begin
                Move True to bFail
                Send Info_Box "Please enter a doctor number." (psMboxCaption(Self))
            End
            Function_Return bFail
        End_Function
        
        Function ValidateTime Integer iColumn Integer iValue Returns Boolean
            Boolean bFail
            Integer iRecnum
            
            Move False to bFail
            Move OFFAPPTS.RECNUM to iRecnum
            Clear OFFAPPTS
            Move iValue to OFFAPPTS.Time
            Find eq OFFAPPTS by Index.1
            If (not(Found)) Begin
                Move True to bFail
                Send Info_Box ("At least one time field is invalid. Please select a valid Start Time, Lunch Hour, and End Time from the selection prompt.") (psMboxCaption(Self))
            End
            
            If (iRecnum and (iRecnum <> OFFAPPTS.RECNUM)) Begin
                Clear OFFAPPTS
                Move iRecnum to OFFAPPTS.RECNUM
                Find eq OFFAPPTS by recnum
            End
            Function_Return bFail
        End_Function
    End_Object

    Set Main_DD to oDOCTOR_DD
    Set Server to oDOCTOR_DD

    

    Object oDOCTOR_DOCTOR_ is a dbForm
        Entry_Item DOCTOR.DOCTOR#
        Set Location to 13 12
        Set Size to 13 66
        Set Label to "Doctor #"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oDOCTOR_TITLE is a dbForm
        Entry_Item DOCTOR.TITLE
        Set Location to 13 84
        Set Size to 13 126
        Set Label to "Title"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oDOCTOR_LAST_NAME is a dbForm
        Entry_Item DOCTOR.LAST_NAME
        Set Location to 37 12
        Set Size to 13 73
        Set Label to "Last"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oDOCTOR_FIRST_NAME is a dbForm
        Entry_Item DOCTOR.FIRST_NAME
        Set Location to 37 92
        Set Size to 13 83
        Set Label to "First"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oDOCTOR_MIDDLE_INIT is a dbForm
        Entry_Item DOCTOR.MIDDLE_INIT
        Set Location to 37 187
        Set Size to 13 23
        Set Label to "Middle"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oLineControl1 is a LineControl
        Set Size to 2 197
        Set Location to 56 12
    End_Object

    Object oDOCTOR_ADDR1 is a dbForm
        Entry_Item DOCTOR.ADDR1
        Set Location to 69 12
        Set Size to 13 197
        Set Label to "Address 1"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oDOCTOR_ADDR2 is a dbForm
        Entry_Item DOCTOR.ADDR2
        Set Location to 92 12
        Set Size to 13 197
        Set Label to "Address 2"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oDOCTOR_CITY is a dbForm
        Entry_Item DOCTOR.CITY
        Set Location to 115 12
        Set Size to 13 71
        Set Label to "City"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oDOCTOR_STATE is a dbForm
        Entry_Item DOCTOR.STATE
        Set Location to 115 110
        Set Size to 13 20
        Set Label to "State"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oDOCTOR_ZIP is a dbForm
        Entry_Item DOCTOR.ZIP
        Set Location to 115 160
        Set Size to 13 49
        Set Label to "Zip"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oLineControl1 is a LineControl
        Set Size to 2 197
        Set Location to 135 12
    End_Object

    Object oDOCTOR_HOME_PHONE is a dbForm
        Entry_Item DOCTOR.HOME_PHONE
        Set Location to 148 12
        Set Size to 13 66
        Set Label to "Home Phone"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oDOCTOR_CELL_PHONE is a dbForm
        Entry_Item DOCTOR.CELL_PHONE
        Set Location to 170 12
        Set Size to 13 66
        Set Label to "Cell Phone"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oDOCTOR_PAGER is a dbForm
        Entry_Item DOCTOR.PAGER
        Set Location to 194 12
        Set Size to 13 66
        Set Label to "Pager"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
    End_Object

    Object oLineControl2 is a LineControl
        Set Size to 63 3
        Set Location to 145 112
        Set Horizontal_State to False
    End_Object

    Object oDOCTOR_START_TIME is a dbForm
        Entry_Item DOCTOR.START_TIME
        Set Location to 148 149
        Set Size to 13 60
        Set Label to "Start"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
        Set Prompt_Button_Mode to PB_PromptOn
        
        Procedure Prompt
            Integer iTime
            
            Send Popup of oOfficeTimesSL
            If (DidAcceptSelection(oOfficeTimesSL)) Begin
                Get GetSelectedTime of oOfficeTimesSL to iTime
                Set Field_Changed_Value of oDOCTOR_DD Field DOCTOR.START_TIME to iTime
            End
        End_Procedure
        
    End_Object

    Object oDOCTOR_LUNCH_HOUR is a dbForm
        Entry_Item DOCTOR.LUNCH_HOUR
        Set Location to 170 149
        Set Size to 13 60
        Set Label to "Lunch"
        Set Prompt_Button_Mode to PB_PromptOn
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
        
        Procedure Prompt
            Integer iTime
            
            Send Popup of oOfficeTimesSL
            If (DidAcceptSelection(oOfficeTimesSL)) Begin
                Get GetSelectedTime of oOfficeTimesSL to iTime
                Set Field_Changed_Value of oDOCTOR_DD Field DOCTOR.LUNCH_HOUR to iTime
            End
        End_Procedure
    End_Object

    Object oDoctor_End_Time is a dbForm
        Entry_Item DOCTOR.END_TIME
        Set Location to 194 149
        Set Size to 13 60
        Set Label to "End"
        Set Label_Col_Offset to 0
        Set Label_Justification_Mode to JMode_Top
        Set Prompt_Button_Mode to PB_PromptOn
        
        Procedure Prompt
            Integer iTime
            
            Send Popup of oOfficeTimesSL
            If (DidAcceptSelection(oOfficeTimesSL)) Begin
                Get GetSelectedTime of oOfficeTimesSL to iTime
                Set Field_Changed_Value of oDOCTOR_DD Field DOCTOR.END_TIME to iTime
            End
        End_Procedure
    End_Object

Cd_End_Object
